<!DOCTYPE html>
<html>
<head>
  <title>登陆 - 里客云</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="../../css/bootstrap.min.css">
  <script src="../../js/jquery-3.4.1.min.js"></script>
  <style type="text/css">
    .container{
      width: 90%;
      margin-top: 50px;
    }
    h3{
      text-align: center;
      margin-bottom: 30px;
      color: #666;
    }
    .container .jumbotron{
      padding: 20px 30px;
    }
    .container .jumbotron .form-control{
      height: 50px;
      margin-top: -10px;
    }
    .container .jumbotron .btn-dark{
      height: 45px;
      display: block;
      width: 120px;
      margin:20px auto 0;
    }
    .container .jumbotron .tips{
      text-align: center;
      color: #666;
      margin-top: 20px;
      font-size: 17px;
    }
    .container .jumbotron .tips a{
      text-decoration: none;
      color: #666;
    }
    .container .Result{
      width: 100%;
      height: 50px;
      display: none;
      margin-top: -10px;
    }
    /*去掉输入框黄色背景*/
    input:-webkit-autofill, 
    input[type=text]:focus, input[type=password]:focus, textarea:focus {
      -webkit-box-shadow: 0 0 0 1000px white inset; 
    }
    .container .jumbotron .wxlogin{
      width: 40px;
      height: 40px;
      margin:10px auto;
    }
    .container .jumbotron .wxlogin img{
      width: 40px;
      height: 40px;
      border-radius: 100%;
    }
  </style>
</head>
<body>

<div class="container">
  <div class="jumbotron">
    <h3>登陆账号</h3>
    <form onsubmit="return false" id="logincheck">
      <div class="input-group mb-3">
        <input type="text" class="form-control" placeholder="请输入里客云账号" name="user">
      </div>
      <div class="input-group mb-3">
        <input type="password" class="form-control" placeholder="请输入密码" name="pwd">
      </div>
      <!-- 登陆按钮 -->
      <button type="submit" class="btn btn-dark" onclick="logincheck();">立即登录</button>
    </form>
    <!-- TIPS -->
    <p class="tips"><a href="../reg">注册账号</a>&nbsp;&nbsp;&nbsp;<a href="../fpwd">找回密码</a></p>
    <!-- WXLOGIN -->
    <div class="wxlogin" style="display: none;"><a href="https://payjs.cn/api/openid?mchid=1511820741&callback_url=https://www.likeyun.cn/m/loginreg/wxlogin.php"><img src="./wxlogo.jpg"></a></div>
  </div>

  <!-- 反馈 -->
  <div class="Result"></div>
</div>

<!-- ajax登录验证 -->
<script>
function logincheck(){
    $.ajax({
        type: "POST",
        url: "./logincheck.php",
        data: $('#logincheck').serialize(),
        success:function(data){
          // 登录成功
          if (data.code == 100) {
            $(".container .Result").css("display","block");
            $(".container .Result").html('<div class="alert alert-success"><strong>'+data.msg+'</strong></div>');
            location.href="javascript:history.go(-1)";
          }else{
            // 登陆失败
            $(".container .Result").css("display","block");
            $(".container .Result").html('<div class="alert alert-danger"><strong>'+data.msg+'</strong></div>');
          }
        },
        error:function(data) {
          // 服务器发生错误
          $(".container .Result").css("display","block");
          $(".container .Result").html("<div class=\"alert alert-danger\"><strong>服务器发生错误</strong></div>");
        }
    });
}

// 当页面在微信打开的时候，才显示微信登陆按钮
var ua = navigator.userAgent.toLowerCase();
var isWeixin = ua.indexOf('micromessenger') != -1;
window.onload=function(){
  if (isWeixin) {
    // 如果是在微信打开当前页面
    $(".container .wxlogin").css("display","block");
  }else{
    // 如果不是，就不做处理
  }
}
</script>
</body>
</html>